<%@ page
        import="org.wso2.carbon.governance.custom.lifecycles.checklist.ui.clients.LifecycleServiceClient" %>
<%
    try {
        LifecycleServiceClient lifecycleServiceClient = new LifecycleServiceClient(config, request.getSession());

        String path = request.getParameter("path");
        String aspect = request.getParameter("aspect");
        String action = request.getParameter("action");
        String[] items = request.getParameterValues("items");   /* "true, false, true, false"*/
        String parameterString = request.getParameter("parameterString");

        System.out.println("parameterString:" + parameterString);

        String[][] parameterArray = {};

        if (!parameterString.trim().equals("")) {
            String[] keySetWithValues = parameterString.split("\\^\\|\\^");
            parameterArray = new String[keySetWithValues.length][2];

            for (int i = 0; i < keySetWithValues.length; i++) {
                String keySetWithValue = keySetWithValues[i];
                String[] keyAndValue = keySetWithValue.split("\\^\\^");
                System.out.println("keyAndValue:" + keyAndValue.length);
                parameterArray[i][0] = keyAndValue[0];
                parameterArray[i][1] = keyAndValue[1];
            }
        }

        for(String[] arr : parameterArray) {
            for (String t : arr) {
                System.out.println("t:" + t);
            }
        }

        //InvokeAspectProcessor.invokeAspect(request, config);
        lifecycleServiceClient.invokeAspectWithParams(path, aspect, action, items, parameterArray);
    } catch (Exception e) {
        response.setStatus(500);
        e.printStackTrace();
%><%=e.getMessage()%><%
        return;
    }
%>
